<template>
  <div id="app">
    <router-view/>
  </div>
</template>
<script>
    export default {
        data() {
            return {

            }
        },
        created() {
            this.$eventHub.$on('webSocketError', (res)=>{
                this.$message.error(res);
            });
            if(this.getUID()){
                this.$eventHub.$on('webSocketInit', (res)=>{
                    if(res){
                        this.getTokenWebSocket();
                    }
                });
                this.$eventHub.$on('auth', (res)=>{
                    if(res){
                        this.setWebSocketToken(res.token);
                    }
                });
            }

        },
        beforeDestroy(){
            this.$eventHub.$off('webSocketError');
            this.$eventHub.$off('webSocketInit')
        },
        methods:{
            getTokenWebSocket(){
                let param={
                    "op":"auth",
                    "token":this.getToken(),
                    "userid":this.getUserName(),
                    "strategyid":"",
                    "data":null
                };
                this.$webSocket.send(JSON.stringify(param));
            },
        }
    }
</script>
<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
}
*{ padding: 0px; margin: 0px; text-decoration: none; list-style: none;}
  .fl-left{float: left;}
  .fl-right{float: right;}
  .clear{clear:both;}
.contain{ width: 1200px; margin: 0 auto;}
</style>
